import { defineConfig } from "vite";
import { resolve } from "path";
import vue from "@vitejs/plugin-vue";

const root = process.cwd();

// 路径查找
function pathResolve(dir) {
  return resolve(root, ".", dir);
}
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    open: true,
    host: true,
    // proxy: {
    //   "/api": {
    //     target: "http://example.com",
    //     changeOrigin: true,
    //     rewrite: path => path.replace(/^\/api/, ""),
    //   },
    // },
  },
  resolve: {
    alias: [
      {
        find: /@\//,
        replacement: `${pathResolve("src")}/`,
      },
    ],
  },
});
